'use strict';

/**
 * @ngdoc function
 * @name webApp.controller:SetupCtrl
 * @description
 * # SetupCtrl
 * Controller of the webApp
 */
angular.module('webApp')
  .controller('setUp', function ($scope,CacheFactory,cookie,popBox,$location,$ionicHistory) {
  $scope.setupBars = [
    {
      name: '关于我们'
    },
    {
      name: '清理缓存'
    }
  ];
  //清理缓存
  $scope.setUp = function(index){
    if(index == 1){
      //清理接口缓存
      CacheFactory.clearAll();
      //清理cookie
      cookie.delCookie('newsId');
      cookie.delCookie('replayId');
      cookie.delCookie('column_id');
      //清理路由历史记录
      $ionicHistory.clearHistory();
      $ionicHistory.clearCache();
      popBox.showConfirm('提示','缓存清理成功3秒后刷新页面重新载入！');
      setTimeout(function(){
        window.location.reload();
      },3000);
    }
    else{
      $location.path('/root/aboutUs');
    }
  };
});
